import {MealType} from "@/api/types/meal";
import request from "@/utils/request";
import {DeadlineRequest, DeadlineResponse} from "@/api/types/deadline";
import {BaseResponse} from "@/api/types/baseResponse";

// 公用的 API 地址
const URL = "/system/deadline"

// 查询所有的截单时间
export async function getDeadlines() {
    return await request.get<BaseResponse<DeadlineResponse[]>, BaseResponse<DeadlineResponse[]>>(URL)
}

// 根据套餐类型查询截单时间
export async function getDeadlineByMealType(mealType: MealType) {
    return await request.get<BaseResponse<DeadlineResponse[]>, BaseResponse<DeadlineResponse[]>>(URL, {params: {type: mealType}})
}

// 根据套餐类型修改截单时间
export async function updateDeadlineByMealType(data: DeadlineRequest) {
    return await request.put<BaseResponse<boolean>, BaseResponse<boolean>>(URL, data)
}
